package com.sunbo509.www.gridview;

import android.app.AlertDialog;

import android.content.DialogInterface;
import android.content.Intent;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.sunbo509.www.gridview.fragment.dialogFragment;
import com.sunbo509.www.gridview.smooth.SmoothActivity;

import es.dmoral.toasty.Toasty;
import tyrantgit.explosionfield.ExplosionField;

public class LayoutActivity extends AppCompatActivity implements dialogFragment.InputListener {
    private Button btn_location,btn_dialog,btn_dialog1,
                    btn_shuibowen,btn_putong ,btn_explose,
                    btn_Toast1,btn_Toast2,btn_Toast3,
                    btn_Media,btn_guide,  btn_smooth;

    private TextView tv_num,tv_pwd;



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.layout,menu);
        return super.onCreateOptionsMenu(menu);
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.userset:
              Toast.makeText(this,"6666",Toast.LENGTH_SHORT).show();
                break;
            case R.id.userset1:
                item.setTitle("孙博");
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout);

        btn_location=(Button)findViewById(R.id.btn_location);
//        rip=(RippleView)findViewById(R.id.rip);
//        rip1=(RippleView)findViewById(R.id.rip1);

        btn_location.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Intent intent=new Intent(getApplicationContext(),LocationActivity.class);
               startActivity(intent);
           }
       });

        btn_dialog=(Button)findViewById(R.id.btn_dialog);
        btn_dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final AlertDialog.Builder builder=new AlertDialog.Builder(LayoutActivity.this);
                builder.setTitle("弹出框")
                        .setMessage("这是弹出框的内容")
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                               Toast.makeText(getApplicationContext(),"点击了确定按钮",Toast.LENGTH_SHORT).show();
                                dialog.dismiss();
                            }
                        })
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Toast.makeText(getApplicationContext(),"点击了取消按钮",Toast.LENGTH_SHORT).show();
                             dialog.dismiss();
                            }
                        })
              .show();
            }
        });
          btn_dialog1=(Button)findViewById(R.id.btn_dialog1);
           tv_num=(TextView)findViewById(R.id.tv_num);
           tv_pwd=(TextView)findViewById(R.id.tv_pwd);
          btn_dialog1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                  dialogFragment fragment=new dialogFragment();
                  fragment.show(getFragmentManager(),"dialogFragment");
            }
        });

        btn_shuibowen=(Button)findViewById(R.id.button4);
        btn_putong=(Button)findViewById(R.id.button5);
        btn_explose=(Button)findViewById(R.id.btn_explose);
        btn_putong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        btn_explose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ExplosionField explosionField=ExplosionField.attach2Window(LayoutActivity.this);
                explosionField.explode(btn_explose);
            }
        });

   Toasty.Config.getInstance()
           .setSuccessColor(getResources().getColor(R.color.green))
           .setErrorColor(getResources().getColor(R.color.red))
           .setTextColor(getResources().getColor(R.color.black))
           .setTextSize(15)
           .apply();

        btn_Toast1=(Button)findViewById(R.id.btn_Toast1);
        btn_Toast2=(Button)findViewById(R.id.btn_Toast2);
        btn_Toast3=(Button)findViewById(R.id.btn_Toast3);
        btn_Toast1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toasty.success(LayoutActivity.this,"成功效果",Toast.LENGTH_SHORT).show();
            }
        });
        btn_Toast2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Toasty.error(LayoutActivity.this,"失败效果",Toast.LENGTH_SHORT).show();
            }
        });
        btn_Toast3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            Toasty.normal(LayoutActivity.this,"标准效果",Toast.LENGTH_LONG).show();
            }
        });

        btn_Media=(Button)findViewById(R.id.btn_Media);
        btn_Media.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(LayoutActivity.this,Media2Activity.class);
                startActivity(intent);
            }
        });

        btn_guide=(Button)findViewById(R.id.guide);
        btn_guide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(LayoutActivity.this,GuideActivity.class);
                startActivity(intent);
            }
        });

         btn_smooth = (Button) findViewById(R.id.btn_smooth);
        btn_smooth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(LayoutActivity.this,SmoothActivity.class);
                startActivity(intent);
            }
        });




    }


    //dialogframent传值接收接口
    @Override
    public void OninputComplete(String num, String pwd) {
        tv_num.setText(num);
        tv_pwd.setText(pwd);
    }







}
